package ooexercise04;
import java.util.Timer;
import java.util.TimerTask;
public class TimerDemo{
    public static void main(String[] args) {
        Timer timer = new Timer();
        int interval = 1000;
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("快去学习");
            }
        },interval,interval);
    }
}




















/*
import java.util.TimerTask;
import java.util.Timer;
public class TimerDemo {
    public static void main(String[] args) {
        Timer timer = new Timer();
        int interval = 1000;
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("去写代码");
            }
        },interval,interval);
    }
}

 */
